//
//  NSAttributedString+m.m
//  AFNetworking
//
//  Created by baboy on 2019/2/18.
//

#import <Foundation/Foundation.h>
#import "NSAttributedString+x.h"

@implementation NSAttributedString(x)
+ (CGSize)sizeOfString:(NSString*) s withFont:(UIFont *)font constrainedToSize:(CGSize) size{
    NSAttributedString *attributedText = [[NSAttributedString alloc] initWithString:s attributes:@ {NSFontAttributeName: font}];
    CGRect rect = [attributedText boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin context:nil];
    return rect.size;
}
+(CGSize)sizeOfString:(NSString *)s withFont:(UIFont *)font{
    CGSize size = [self sizeOfString:s withFont:font constrainedToSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)];
    return size;
}
@end
